package com.laich.springcloud.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.laich.springcloud.entity.User;
import com.laich.springcloud.service.UserService;


@RestController
@RequestMapping("/user")
public class UserController {
	
	@Value("${server.port}")
	private String port;

	@Autowired
    private UserService userService;

    @RequestMapping(value = "/registry",method = RequestMethod.POST)
    public User createUser( @RequestParam("username") String username
    , @RequestParam("password") String password) {
        return userService.create(username,password);
    }
    
    @RequestMapping(value = "/findByUserName/{username}")
    public User findByUserName( @PathVariable("username") String username) {
    	System.out.println("----"+port);
        return userService.findByUsername(username);
    }
    @RequestMapping(value = "/getUser")
    public User getUser( @RequestParam("id") String id) {
        return userService.getUser(id);
    }
	
    
}
